#include "Board.hpp"
#include "Tower.hpp"

#include "ResourceManager.hpp"


Board::Board(sf::RenderWindow* window, const TowerPanel* towerPanel)
    : ::Panel(window,
              sf::Vector2f(0, 50),
              sf::Vector2f(555, 525),
              ResourceManager<sf::Sprite>::instance()->get("Board_BG")),
      towerPanel_(towerPanel)
{
    towerGrid_.fill(nullptr);
}

Board::~Board()
{}

void
Board::render()
{
    static sf::RectangleShape white(sf::Vector2f(35, 35));

    white.setFillColor(sf::Color(255, 255, 255, 127));
    window_->draw(*background_);

    for (unsigned i = 0; i < 11; ++i)
    {
        for (unsigned j = 0; j < 13; ++j)
        {
            if (towerGrid_.at(i * 11 + j) == nullptr)
            {
                white.setPosition(position_.x + 50 + j * 35, position_.y + 50 + i * 35);
                window_->draw(white);
            }
        }
    }
}

void
Board::handleEvents(const sf::Event&)
{}
